# -*- coding: utf-8 -*-
import redis


_REDIS_KEY_PREFIX = 'bigbang'
redis_client = redis.StrictRedis(host='103.230.243.233',
                                 port=6379)


def prefix_key(key, prefix=_REDIS_KEY_PREFIX):
    return '%s:%s' % (prefix, key)


def set_activity_switch(activity_type, status):
    key = prefix_key('activity:{}:off'.format(activity_type))
    return redis_client.set(key, status)


def get_activity_switch(activity_type):
    key = prefix_key('activity:{}:off'.format(activity_type))
    return int(redis_client.get(key) or 0)
